<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/2/18
 * Time: 20:06
 */

use think\facade\Db;

//后台开发基类
class admin_base
{
    public $Where = array(
        'static' => 1,
        'del' => 1,
    );

    public function __construct()
    {
        if (WEKCMS !== true) {
            $execute_time = sys_over_time();
            $msg = "<h1 style='text-align: center;margin-top: 5%;'>wekcms内容管理系统!</h1><p style='text-align: center;'>程序执行时间：{$execute_time}秒</p>
    <p style='text-align: center;'><a href='https://gitee.com/wekyun/wekcms/stargazers'><img src='https://gitee.com/wekyun/wekcms/badge/star.svg?theme=dark' alt='star'></img></a></p>";
            echo $msg;
            exit();
        }
        //验权
//        initDb();//数据库链接
        base::load_sys_class('validata');

    }

    public function chech_action()
    {
        $action = ROUTE_M . '_' . ROUTE_C . '_' . ROUTE_A;
        //登录一定有 action，登录如果没有权限，都进不来
        if (!isset($_SESSION['action']) || !in_array($action, $_SESSION['action'])) {
            $execute_time = sys_over_time();
            $msg = "<h1 style='text-align: center;margin-top: 5%;'>wekcms内容管理系统!</h1><p style='text-align: center;'>程序执行时间：{$execute_time}秒</p>
    <p style='text-align: center;'><a href='https://gitee.com/wekyun/wekcms/stargazers'><img src='https://gitee.com/wekyun/wekcms/badge/star.svg?theme=dark' alt='star'></img></a></p>";
            echo $msg;
            exit();
        }
    }

    public function check_login()
    {
        if (!isset($_SESSION['action'])) {
            redirect('http://www.baidu.com');
        }
    }
}